import { Component , OnInit } from '@angular/core';

import { Util } from '../../utils/util';

import { ShopDetailService } from './shop.detail.page.service';

import { Scope } from '../../utils/emit';

@Component({
  selector:'app-brand-detail',
  templateUrl: './shop.detail.page.html',
  providers:[ShopDetailService]
})
export class ShopDetailPage implements OnInit{

  shopInfo:any;
  instest:boolean = false;

  constructor(private service:ShopDetailService,private util:Util,private scope:Scope){}


  ngOnInit(){

    this.shopInfo = this.util.sessionStore().get('shopDetail');

    this.getShopInfo();

    this.getShopDoubleInfo();

    // console.log(this.shopInfo);

  }



  ngOnDestroy() {

    if(this.OffEvent){
      this.OffEvent.unsubscribe();
    }

    if(this.OffDoubleEvent){
      this.OffDoubleEvent.unsubscribe();
    }

  }

  OffEvent:any;
  getShopInfo(){

    let _shop = this.util.sessionStore().get('shopDetail');

    let json = {
      uid: _shop.uid
    };

    var res = {"code":0,"msg":"成功","data":{"t":{"id":"725677994","uid":"725677994","nick":"天猫超市","sid":"67597230","shopType":"商城","shopName":"天猫超市","shopCreateTime":"2011-06-28 14:48:53.0","mainCategory":"百货/餐具/家庭保健--洗护清洁剂/卫生巾/纸/香薰","shopLevel":20,"loc":"上海","province":"上海","city":null,"monthSellAmount":109997894,"monthSellMoney":3.56287788257E9,"sellAmount":3726328,"sellMoney":9.81308616E7,"productCount":35105,"modifyTime":"2017-12-04 05:08:26.0","ifashion":0,"date":null,"reason":null},"interest":true}};

    setTimeout(()=>{

      // this.shopInfo = res.data.t;

      this.shopInfo = this.util.shopLevels(res.data.t);

      this.instest = res.data.interest;

    },100);
  }

  // 11.11预售
  shopDoble:any = {
    sellAmount: 0,
    dingJin: 0,
    sellMoney: 0
  };
  OffDoubleEvent:any;
  getShopDoubleInfo(){

    let _shop = this.util.sessionStore().get('shopDetail');

    let json = {
      uid: _shop.uid
    };

    this.shopDoble = {
      sellAmount: 0,
      dingJin: 0,
      sellMoney: 0
    };

    var res = {"code":0,"msg":"成功","data":{"sellAmount":0,"dingJin":0.0,"sellMoney":0.0}};

    setTimeout(()=>{

      // this.shopInfo = res.data.t;
      if(res.data){
        this.shopDoble = res.data;
      }



    },100);
  }
}
